package com.check.utils;

import com.check.bean.FileItem;

import java.util.List;

/**
 * @description:
 * @Author: zyt
 */
public class ListUtils {
    /**
     * 将FileItem集合转换成FileItem.name的字符数组
     * @param list
     * @return
     */
    public static String[] fileItemsToStringArrays(List<FileItem> list){
        String[] fileNames = new String[list.size()];
        for (int i = 0; i < list.size(); i++) {
            fileNames[i] = list.get(i).getName();
        }
        return fileNames;
    }

    public static FileItem findIndexByName(String name,List<FileItem> items){
        for (FileItem item : items) {
            if(item.getName().equals(name)){
                return item;
            }
        }
        return null;
    }
}
